//
//  HMEmoticon.swift
//  微博
//
//  Created by 程双岐 on 16/10/6.
//  Copyright © 2016年 heima. All rights reserved.
//

import UIKit

class HMEmoticon: NSObject,NSCoding {
    
    var chs: String?
    
    var png: String?
    
    var type: String?
    
    var code: String?
    
    var path: String?
    
    var folderName: String?
    
    func encode(with aCoder: NSCoder) {
        aCoder.encode(chs, forKey: "chs")
        aCoder.encode(png, forKey: "png")
        aCoder.encode(type, forKey: "type")
        aCoder.encode(code, forKey: "code")
        aCoder.encode(path, forKey: "path")
        aCoder.encode(folderName, forKey: "folderName")

    }
    //使用yymodel如果进行归档需要提供默认的构造函数
    override init(){
        super.init()
    }
    
    required init?(coder aDecoder: NSCoder) {
       chs = aDecoder.decodeObject(forKey: "chs") as? String
        png = aDecoder.decodeObject(forKey: "png") as? String
        type = aDecoder.decodeObject(forKey: "type") as? String
        code = aDecoder.decodeObject(forKey: "code") as? String
        path = aDecoder.decodeObject(forKey: "path") as? String
        folderName = aDecoder.decodeObject(forKey: "folderName") as? String
  
        if type == "0" {
            let imagePath = HMEmoticonTools.shareTools.emoticonBundle.path(forResource: folderName, ofType: nil)! + "/" + png!
            path = imagePath
        }
    }

}
